import mysql.connector


def get_user_list():
    mydb = get_database()
    myCursor = mydb.cursor()

    myCursor.execute("select * from user")
    myResult = myCursor.fetchall()
    for x in myResult:
        print(x)


def get_database():
    mydb = mysql.connector.connect(
        host="localhost",
        user="root",
        password="root",
        database="test"
    )
    return mydb


def insert_user():
    mydb = get_database()
    myCursor = mydb.cursor()
    myCursor.execute("INSERT INTO `test`.`user`(`id`, `name`, `age`) VALUES (%s ,%s,%s)", (11, "11", 11))
    myResult = myCursor.fetchall()
    for x in myResult:
        print(x)
    mydb.commit()
    print("---------------------")


get_user_list()
